
//pages/home/home.ts
const childs:Map<string, boolean> = new Map<string, boolean>()
childs.set('Hot', true)
childs.set('Ad', true)
childs.set('XianWu', true)
Page({
  data: {
    active:'Home',
    list:[{name:'Home',icon:'home-o',desc:'首页'},
          {name:'Hot',icon:'hot-o',desc:'热点'},
          {name:'Ad',icon:'friends-o',desc:'公告'},
          {name:'XianWu',icon:'gift-o',desc:'闲物'},
          {name:'Me',icon:'manager-o',desc:'我'}]
  },
  onChange(e:any) {
    let active = e.detail
    if(this.data.active !== active){
      this.setData({active:active})
    }
  },
  onToupper(e:any){
    const name = this.data.active
    if(!childs.has(name)){
      return
    } 
    var id = `#${name} `
    const child = this.selectComponent(id);
    if(child !== null){
      child.onScroll(e)
    }
  },
  onTolower(e:any){
    const name = this.data.active
    if(!childs.has(name)){
      return
    }   
    var id = `#${name} `
    const child = this.selectComponent(id);
    if(child !== null){
      child.onScroll(e)
    }
  }
})